package com.song.pattern.singleton;

import java.util.Vector;

public class GlobalConfig {
	private static GlobalConfig instance = null;
	private Vector properties = null;
	
	public Vector getProperties(){
		return properties;
	}
	
	private GlobalConfig(){
		//Load configuration information from DB or file  
	     //Set values for properties  
		//私有构造参数: 加载配置信息
	}
	
	private static synchronized void synInit(){
		if(instance == null){
			instance = new GlobalConfig();
		}
	}
	
	public static GlobalConfig getInstance(){
		if(instance == null){
			synInit();
		}
		return instance;
	}
	
	public void updateProperties(){
		 //Load updated configuration information by new a GlobalConfig object  
		//内部创建新的实例: 重新加载配置信息
		GlobalConfig shadow = new GlobalConfig();
		properties = shadow.getProperties();
	}
}
